package treeView;

import gettree.TreeNode;

import org.antlr.runtime.tree.Tree;

public class TreeWrapper {
	
	private String label="" ; 
	private TreeNode tree ;
	private String rule="" ;
	private int ruleNr=-1 ; 
	private int h = -1 ;
	
	public int getH (){
		if (h==-1)
			h = getH(tree);
		return h ;
	}
	
	public int getH(TreeNode t){
		if (t == null)
			return 0 ;
		int max = 0 ;
		for (int i = 0 ; i< t.getChildCount() ; i++){
			int h = getH(t.getChild(i));
			if (max < h)
				max = h ;
		}
		return 1 + max ;
	}
	
	public String getLabel() {
		return label;
	}
	
	public void setLabel(String name) {
		this.label = name;
	}
	
	public TreeNode getTree() {
		return tree;
	}
	
	public void setTree(TreeNode tree) {
		this.tree = tree;
	}
	
	public String getRule() {
		return rule;
	}
	
	public void setRule(String rule) {
		this.rule = rule;
	}
	
	public int getRuleNr() {
		return ruleNr;
	}
	
	public void setRuleNr(int ruleNr) {
		this.ruleNr = ruleNr;
	}
	
	public String toString(){
		if (label.trim().isEmpty())
			return tree.getLabel();
		return label;
	}
}
